package org.odk.clinic.android.activities;

import org.odk.clinic.android.R;
import org.odk.clinic.android.database.SQLiteAdapter;

import android.app.ListActivity;
import android.database.Cursor;
import android.os.Bundle;
import android.widget.SimpleCursorAdapter;

public class ViewProblemActivity extends ListActivity {
	private SQLiteAdapter mDB;
	private Cursor mCursor;
	protected void onCreate(Bundle ici){
		super.onCreate(ici);
		setContentView(R.layout.list_problem);
		//
		mDB = new SQLiteAdapter(this);
		mDB.open();
		//
		int mid = DetailPatientActivity.mid;
		mCursor = mDB.getAllProblem(mid);
		if(mCursor.moveToFirst()){
			do{
				startManagingCursor(mCursor);
				String[] from = new String[]{SQLiteAdapter.KEY_PROBLEM_NAME,SQLiteAdapter.KEY_PROBLEM_DESC};
				int[] to = new int[]{R.id.problem_name,R.id.problem_desc};
				SimpleCursorAdapter per = new SimpleCursorAdapter(this,R.layout.list_problem_item,mCursor,from,to);
				setListAdapter(per);
			}while (mCursor.moveToNext());
		}
		
	}

}
